package com.itheima.tliasbackend.mapper;

import com.itheima.tliasbackend.pojo.Emp;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface EmpMapper {

    Integer selectCount(String name, Integer gender, LocalDate begin, LocalDate end);

    @Select("select * from emp")
    List<Emp> selectList(String name, Integer gender, LocalDate begin, LocalDate end);

    /**
     * 根据IDs删除员工
     *
     * @param idList id列表
     */
    void deleteByIds(List<Integer> idList);

    /**
     * 新增员工信息
     *
     * @param emp 员工信息
     */
    void insert(Emp emp);

    @Select("select * from emp where id = #{id}")
    Emp selectById(Integer id);

    void updateById(Emp emp);

    /**
     * 根据用户名和密码查询用户信息
     *
     * @param username
     * @param password
     * @return
     */
    @Select("select id, username, password, name, gender, image, job, entrydate, dept_id, create_time, update_time" +
            " from emp where username = #{username} and password = #{password}")
    Emp selectByUsernameAndPassword(String username, String password);

    @Delete("delete from emp where dept_id = #{deptId}")
    void deleteByDeptId(Integer deptId);
}
